f = open('24.txt','r')
s = f.readline()+'VVV'
i = 0
L, G = 0, 0
while i<len(s):
    if (s[i] == 'X' and s[i+2] == 'X') or (s[i] == 'Y' and s[i+2] == 'Y'):
        #print(s[i]+s[i+1]+s[i+2])
        L +=1
        i+=3
    else:
        G = max(G,L)
        L = 0
        i+=1
print(G)